﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BLL;
using Microsoft.VisualBasic;
namespace 健身房管理
{
    public partial class Login : Form
    {
       
        public Login()
        {
            InitializeComponent();
            
        }
        zhanghaoBLL zhb = new zhanghaoBLL();
        huiyuanBLL hyb = new huiyuanBLL();
        private void closebtn_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
       
        private void textBox1_Click(object sender, EventArgs e)
        {
            this.textBox1.BackColor = Color.White;
            panel3.BackColor = Color.White;
            panel4.BackColor = SystemColors.Control;
            this.textBox2.BackColor = SystemColors.Control;
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            this.textBox2.BackColor = Color.White;
            panel4.BackColor = Color.White;
            this.textBox1.BackColor = SystemColors.Control;
            panel3.BackColor = SystemColors.Control;
        }

        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            this.textBox2.UseSystemPasswordChar = false;  
        }

        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            this.textBox2.UseSystemPasswordChar = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            注册 zc = new 注册();
            zc.Show();
            this.Hide();
        }
        
        private void button1_Click(object sender, EventArgs e)
        {


            int usename = int.Parse(this.textBox1.Text);  //获取账号文本框的值
            int usepwd = int.Parse( this.textBox2.Text);  //获取密码文本框的值
            DataTable b1 = zhb.zhdl(usename, usepwd);
            DataTable dt = hyb.yhrandom(usename, usepwd);
            if (b1.Rows.Count > 0)
            {
                string test = b1.Rows[0]["isr"].ToString();
                if (int.Parse(test) > 0)
                {
                    DashForm Dszhu = new DashForm();

                    Dszhu.Show();
                }
                else
                {
                   
                   
                    if (dt.Rows.Count>0)
                    {
                        string str = Interaction.InputBox("请输入随机码", "验证", "在这里输入", -1, -1);
                        DataTable dt2 = hyb.yzrandom(int.Parse(str.ToString()));
                        if (dt2.Rows.Count>0)
                        {
                            
                            if (str != "")
                            {
                                
                                UserDashForm User = new UserDashForm();
                                User.random111 =  int.Parse(str.ToString());
                                User.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("验证码错误");
                        }
                        
                        
                    }
                    

                }
            }
            else
            {
                MessageBox.Show("密码错误");
            }
        }

    }
}
